package se.perhamrin.judo.persistance;

import java.sql.ResultSet;
import java.sql.SQLException;

import org.springframework.jdbc.core.RowMapper;

import se.perhamrin.judo.domain.Day;
import se.perhamrin.judo.domain.Time;
import se.perhamrin.judo.domain.UjkSession;

class SessionRowMapper implements RowMapper<UjkSession> {
	public static final String SESSION_DAY = "session_day";
	public static final String DESCRIPTION = "description";
	public static final String START_TIME = "start_time";
	public static final String END_TIME = "end_time";

	public UjkSession mapRow(ResultSet rs, int rowNum) throws SQLException {
		String description = rs.getString(DESCRIPTION);
		Day day = Day.valueOf(rs.getString(SESSION_DAY));
		String bla = rs.getString(START_TIME);
		System.out.println(bla);
		Time start = Time.valueOf(bla);
		Time end = Time.valueOf(rs.getString(END_TIME));
		long id = rs.getLong("id");
		return new UjkSession(id, description, day, start, end);
	}
}